package com.xu.controller;

import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.LineCaptcha;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.RandomUtil;
import com.xu.pojo.VerifyCode;
import com.xu.service.HutoolService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.annotation.Resource;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.UUID;

import static cn.hutool.core.img.ImgUtil.toBufferedImage;

/**
 * @author ：xjm
 * @date ：Created in 2024/7/16 18:08
 * @description：hutool控制类
 */
@Controller
public class HutoolController {

    @Resource
    private HutoolService hutoolService;

    //生成干扰线条验证码
    @GetMapping("/createLineCaptcha")
    public void getLineCaptcha(Model model,HttpServletResponse response)
    {
        String code = RandomUtil.randomNumbers(4);
        VerifyCode.modifyVerifyCode(code);
        hutoolService.getLineCaptcha(code, response);
        model.addAttribute("code", code);
    }


}
